<!DOCTYPE html>
<html>
	<head>
		<title>View Navigator Sample</title>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

		<script src="../../../src/libs/jquery-1.7.1.js"></script>
		<script src="../../../src/libs/jquery.animate-enhanced.js"></script>
		<script src="../../../src/libs/iscroll.js"></script>
		<script src="../../../src/libs/noClickDelay.js"></script>

		<link rel="stylesheet" href="../../../src/viewnavigator/viewnavigator.css" type="text/css" />
		<script src="../../../src/viewnavigator/viewnavigator.js"></script>

		<script>

			$(document).ready( function() {

				//Setup the default view
				var defaultView = getView();
				defaultView.backLabel = null;

				//Setup the ViewNavigator
				window.viewNavigator = new ViewNavigator( 'body' );
				window.viewNavigator.pushView( defaultView );


			} );

			function pushView() {
				//create a view and push it onto the view navigator
				var view = getView();
				window.viewNavigator.pushView( view );
			}

			function popView() {
				//pop a view from the view navigator
				window.viewNavigator.popView();
			}

			function getView() {
				//create a view descriptor with random content
				var bodyView = $('<div>' + Math.random().toString() + '<hr><li href="#" onclick="pushView()" class="viewNavigator_backButton">push view</li> <li href="#" onclick="popView()" class="viewNavigator_backButton">pop view</li><hr>' + getMeat() + '</div>');
				var links = bodyView.find('a');

				return { title: "Default View " + parseInt(Math.random()*1000),
						 backLabel: "Back",
						 view:  bodyView
					   };
			}

			function getMeat() {
				//randomly generate content
				//text string generated by http://baconipsum.com/
				var iterations = 1 + parseInt(Math.random() * 25);
				var result = "";
				for ( var i = 0; i < iterations; i ++ ) {
					result += "Pork chop corned beef meatloaf prosciutto flank, chuck andouille fatback hamburger cow ham turkey. Drumstick filet mignon boudin, salami beef ribs ball tip turducken frankfurter chuck. Pork chop swine chuck meatloaf capicola tri-tip. Pork belly venison bresaola flank, jerky ham hock short loin ground round corned beef salami pork filet mignon tri-tip sirloin. Tenderloin meatball corned beef, boudin brisket bresaola rump short loin tri-tip spare ribs pork belly cow.<hr>"
				}
				return result;
			}

		</script>

	</head>
	<body></body>
</html>
